# define _CRT_SECURE_NO_WARNINGS 1
#pragma once
#include<iostream>
#include<cstring>
#include<cassert>
using std::cout;
using std::cin;
using std::endl;
namespace ForcibleBugMaker
{
	class string 
	{
	public:
		friend void swap(string& s1, string s2);

		typedef char* iterator;
		typedef const char* const_iterator;

		iterator begin();
		iterator end();
		const_iterator begin() const;
		const_iterator end() const;

		// string();
		string(const char* str = "");
		string(const string& s);
		string& operator=(string tmp);
		~string();
		const char* c_str() const;

		size_t size() const;

		char& operator[](size_t pos);
		const char& operator[](size_t pos) const;

		void reserve(size_t n);

		void push_back(char ch);
		void append(const char* str);

		string& operator+=(char ch);
		string& operator+=(const char* str);

		void insert(size_t pos, char ch);
		void insert(size_t pos, const char* str);
		void erase(size_t pos = 0, size_t len = npos);

		size_t find(char ch, size_t pos = 0);
		size_t find(const char* str, size_t pos = 0);

		bool operator>(const string& str) const;
		bool operator==(const string& str) const;
		bool operator>=(const string& str) const;
		bool operator<(const string& str) const;
		bool operator<=(const string& str) const;
		bool operator!=(const string& str) const;

		string substr(size_t pos, size_t len);

		void swap(string& str);

		void clear();

	private:
		char* _str;
		size_t _size;
		size_t _capacity;
		const static size_t npos;
	};

	void swap(string& s1, string s2);

	std::ostream& operator<<(std::ostream& so, const string& str);
	std::istream& operator>>(std::istream& is, string& str);

}